package type1;

import javax.xml.ws.Action;

/**
 * @projectName: com.xiayuanxing.designPattern
 * @className: DispenseState
 * @author: xiayuanxing
 * @description: 发放奖品状态
 * @date: 2022/1/23 14:59
 * @version: 1.0
 */
public class DispenseState extends State{

    //初始化时传入活动引用，扣除积分后改变其状态
    RaffleActivity activity;

    public DispenseState(RaffleActivity activity) {
        this.activity = activity;
    }

    @Override
    public void deductMoney() {
        System.out.println("不能扣除积分");
    }

    @Override
    public boolean raffle() {
        System.out.println("不能抽奖");
        return false;
    }


    @Override
    public void dispensePrize() {
        if (activity.count>0){
            System.out.println("恭喜你中奖了");
            //改变状态为不能抽奖
            activity.setState(activity.getNoRaffleState());
        }else {
            System.out.println("很遗憾，奖品发完了！");
            //改变状态为奖品发放完毕，后面我们就不可以抽奖了
            activity.setState(activity.getDispenseOutState());
        }
    }
}
